<?php
namespace App\Http\Controllers\portal;

use App\Http\Controllers\Controller;
use App\Http\Logic\PortalLogic;
use Illuminate\Http\Request;

class IndexController extends Controller
{
    public function index(Request $request)
    {
        $data = [
            'carousel'        => PortalLogic::getConfig('carousel_photos'),
            'hot_article'     => PortalLogic::getArticleList(['type' =>'hot', 'show_index'=>1], 1, 8),
            'event_photos'    => PortalLogic::getConfig('event_photos'),
            'hotspot_event_photos'    => PortalLogic::getConfig('hotspot_event_photos'),
            'pledge_photos'   => PortalLogic::getConfig('pledge_photos'),
            'foot_article'    => PortalLogic::getArticleFirst(['type' =>'foot', 'show_index'=>1]),
            'history_article' => PortalLogic::getArticleFirst(['type' =>'history', 'show_index'=>1]),
            'founder'         => PortalLogic::getConfig('founder'),
        ];

        return $this->success($data);
    }

    public function config(Request $request)
    {
        $params = $request->all();

        switch ($params['key']) {
            case 'fund':
                $data = [
                    'account_name' => PortalLogic::getConfig('account_name'),
                    'bank_name'    => PortalLogic::getConfig('bank_name'),
                    'card_no'      => PortalLogic::getConfig('card_no'),
                    'remark'       => PortalLogic::getConfig('remark'),
                    'pay_code'     => PortalLogic::getConfig('pay_code'),
                ];
            break;
            case 'founder':
                $data = [
                    'founder' => PortalLogic::getConfig('founder'),
                    'founder_bg'    => asset(\Storage::url(PortalLogic::getConfig('founder_bg')))
                ];
            break;
            default:
                $data = PortalLogic::getConfig($params['key']);
            break;
        }

        return $this->success($data);

    }
}
